﻿ #region Disclaimer/Info
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
 //
 //   File:		GravatarHelper.cs
 //   Website:		http://dexterblogengine.com/
 //   Authors:		http://dexterblogengine.com/About.ashx
 //   Rev:		1
 //   Created:		19/01/2011
 //   Last edit:		19/01/2011
 //   License:		GNU Library General Public License (LGPL)
 // 
 //   For updated news and information please visit http://dexterblogengine.com/
 //   Dexter is hosted to Codeplex at http://dexterblogengine.codeplex.com
 //   For any question contact info@dexterblogengine.com
 //
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #endregion
 
using System;
using System.Web.Mvc;

namespace Dexter.Web.Mvc.Helpers {
	public static class GravatarHelper {
		public static MvcHtmlString GetGravatarUrl ( this HtmlHelper helper, string email, int size ) {
			string hash = email.ToLowerInvariant ( ).ToMd5 ( ).ToLowerInvariant ( );

			string gravatar = string.Concat ( "http://www.gravatar.com/avatar/", hash, "?s=", size, "&d=", "identicon&r=G" );

			return MvcHtmlString.Create ( gravatar );
		}
	}
}
